package cn.com.open.itembank.dto;

import org.springframework.util.StringUtils;

import java.util.ArrayList;
import java.util.List;

/**
 * The type Question import model.
 */
public class QuestionImportModel {
    /**
     * 题型
     */
    private String questionType;
    /**
     * 题型文字
     */
    private String questionTypeName;
    /**
     * 章节
     */
    private String chapter;
    /**
     * 类别
     */
    private String questionCategory;
    /**
     * 类别文字
     */
    private String questionCategoryName;
    /**
     * 题干
     */
    private String prompt;
    /**
     * 选项
     */
    private List<String> choices;
    /**
     * 答案
     */
    private List<String> answer;
    /**
     * 解析
     */
    private String questionAnalysis;
    /**
     * 难度
     */
    private String difficulty;
    /**
     * 分数
     */
    private String score;
    /**
     * 子题
     */
    private List<QuestionImportModel> subItems;
    /**
     * 错误信息
     */
    private String errorInfo;
    /**
     * 备注
     */
    private String remark;

    /**
     * 保存难度文字
     */
    private String saveDiffWord;
    /**
     * 是否客观题
     */
    private String isObjective;

    /**
     * Gets question type.
     *
     * @return the question type
     */
    public String getQuestionType() {
        return questionType;
    }

    /**
     * Sets question type.
     *
     * @param questionType the question type
     */
    public void setQuestionType(String questionType) {
        this.questionType = questionType;
    }

    /**
     * Gets chapter.
     *
     * @return the chapter
     */
    public String getChapter() {
        return chapter;
    }

    /**
     * Sets chapter.
     *
     * @param chapter the chapter
     */
    public void setChapter(String chapter) {
        this.chapter = chapter;
    }

    /**
     * Gets question category.
     *
     * @return the question category
     */
    public String getQuestionCategory() {
        return questionCategory;
    }

    /**
     * Sets question category.
     *
     * @param questionCategory the question category
     */
    public void setQuestionCategory(String questionCategory) {
        this.questionCategory = questionCategory;
    }

    /**
     * Gets prompt.
     *
     * @return the prompt
     */
    public String getPrompt() {
        return prompt;
    }

    /**
     * Sets prompt.
     *
     * @param prompt the prompt
     */
    public void setPrompt(String prompt) {
        this.prompt = prompt;
    }

    /**
     * Gets choices.
     *
     * @return the choices
     */
    public List<String> getChoices() {
        if (choices == null) {
            choices = new ArrayList<>();
        }
        return choices;
    }

    /**
     * Gets answer.
     *
     * @return the answer
     */
    public List<String> getAnswer() {
        if (answer == null) {
            answer = new ArrayList<>();
        }
        return answer;
    }

    /**
     * Gets question analysis.
     *
     * @return the question analysis
     */
    public String getQuestionAnalysis() {
        return questionAnalysis;
    }

    /**
     * Sets question analysis.
     *
     * @param questionAnalysis the question analysis
     */
    public void setQuestionAnalysis(String questionAnalysis) {
        this.questionAnalysis = questionAnalysis;
    }

    /**
     * Gets save diff word.
     *
     * @return the save diff word
     */
    public String getDifficulty() {
        return difficulty;
    }

    /**
     * Sets save diff word.
     *
     * @param difficulty the save diff word
     */
    public void setDifficulty(String difficulty) {
        this.difficulty = difficulty;
    }

    /**
     * Gets score.
     *
     * @return the score
     */
    public String getScore() {
        return score;
    }

    /**
     * Sets score.
     *
     * @param score the score
     */
    public void setScore(String score) {
        this.score = score;
    }

    /**
     * Gets sub items.
     *
     * @return the sub items
     */
    public List<QuestionImportModel> getSubItems() {
        if (subItems == null) {
            subItems = new ArrayList<>();
        }
        return subItems;
    }

    /**
     * Gets error info.
     *
     * @return the error info
     */
    public String getErrorInfo() {
        return errorInfo;
    }

    /**
     * Sets error info.
     *
     * @param errorInfo the error info
     */
    public void setErrorInfo(String errorInfo) {
        this.errorInfo += errorInfo;
    }

    /**
     * Gets remark.
     *
     * @return the remark
     */
    public String getRemark() {
        return remark;
    }

    /**
     * Sets remark.
     *
     * @param remark the remark
     */
    public void setRemark(String remark) {
        this.remark = remark;
    }

    /**
     * Sets choices.
     *
     * @param choices the choices
     */
    public void setChoices(List<String> choices) {
        this.choices = choices;
    }

    /**
     * Sets answer.
     *
     * @param answer the answer
     */
    public void setAnswer(List<String> answer) {
        this.answer = answer;
    }

    /**
     * Gets save diff word.
     *
     * @return the save diff word
     */
    public String getSaveDiffWord() {
        return saveDiffWord;
    }

    /**
     * Sets save diff word.
     *
     * @param saveDiffWord the save diff word
     */
    public void setSaveDiffWord(String saveDiffWord) {
        this.saveDiffWord = saveDiffWord;
    }

    /**
     * Gets is objective.
     *
     * @return the is objective
     */
    public String getIsObjective() {
        return isObjective;
    }

    /**
     * Sets is objective.
     *
     * @param isObjective the is objective
     */
    public void setIsObjective(String isObjective) {
        this.isObjective = isObjective;
    }

    /**
     * Gets question type name.
     *
     * @return the question type name
     */
    public String getQuestionTypeName() {
        return questionTypeName;
    }

    /**
     * Sets question type name.
     *
     * @param questionTypeName the question type name
     */
    public void setQuestionTypeName(String questionTypeName) {
        this.questionTypeName = questionTypeName;
    }

    /**
     * Gets question category name.
     *
     * @return the question category name
     */
    public String getQuestionCategoryName() {
        return questionCategoryName;
    }

    /**
     * Sets question category name.
     *
     * @param questionCategoryName the question category name
     */
    public void setQuestionCategoryName(String questionCategoryName) {
        this.questionCategoryName = questionCategoryName;
    }


    /**
     * Instantiates a new Question import model.
     */
    public QuestionImportModel() {
        this.errorInfo = "";
        this.difficulty = "";
        this.score = "";
        this.prompt = "";
        this.saveDiffWord = "";
        this.questionCategory = "";
        this.questionCategoryName = "";
        this.questionType = "";
        this.questionTypeName = "";
        this.chapter = "";
        this.questionAnalysis = "";
        this.isObjective = "";
        this.remark = "";
        this.choices = new ArrayList<>();
        this.answer = new ArrayList<>();
        this.subItems = new ArrayList<>();
    }

    /**
     * 模型校验.
     *
     * @return the boolean
     */
    public void check() {
        if (StringUtils.isEmpty(this.questionTypeName)) {
            this.errorInfo += "题型名称不能为空；";
        }

        if (StringUtils.isEmpty(this.questionCategoryName)) {
            this.errorInfo += "试题类别不能为空；";
        }

        if (StringUtils.isEmpty(this.saveDiffWord)) {
            this.errorInfo += "难度编码不能为空；";
        }

        // TODO：暂时用中文判断
        if (StringUtils.isEmpty(this.prompt) && !this.questionTypeName.equals("匹配题") && !this.questionTypeName.equals("配伍题")) {
            this.errorInfo += "题目内容不能为空；";
        }

        if (StringUtils.isEmpty(this.score)) {
            this.errorInfo += "分数不能为空；";
        }
    }
}

